package com.fuxin.hanfu.service;

import com.fuxin.hanfu.domain.Cart;
import com.fuxin.hanfu.mapper.CartMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class CartService {
    @Resource
    private CartMapper cartMapper;
    public List<Cart> findList(){
        return cartMapper.selectByExample(null);
    }
    public Cart findById(Integer id){
        return cartMapper.findById(id);
    }
    public Integer insert(Cart cart) {
        try{
            return cartMapper.insert(cart);
        }catch (Exception e){
            // 记录日志
            System.err.println("Error inserting user: " + e.getMessage());
            throw e; // 重新抛出异常以便上层处理
        }

    }
    public Integer update(Cart cart) {
        return cartMapper.update(cart);
    }
    public Integer delete(Integer id) {
        return  cartMapper.delete(id);
    }

}
